
const express = require('express');
const app = express();
const cros = require('cors')
app.use(cros())
app.use(express.urlencoded({ extended: false }));
const expressJWT = require('express-jwt')
const config = require('./config')
// const uploads = multer({dast:path.join(__dirname,'../uploads')})
// app.use(expressJWT({ secret: config.jwtSecretKey }).unless({ path: [/^\/api/] }))
app.use(expressJWT({ secret: config.jwtSecretKey }).unless({ path: [/^\/api/] }))
const userRouter = require('./router/user')
const userinfoRouter = require('./router/userinfo');
const multer = require('multer');
app.use('/api', userRouter)
app.use("/my",userinfoRouter)
app.use(function (err, req, res, next) {
    if (err.name === 'UnauthorizedError') return res.send('身份认证失败！')
})
app.listen(8000, () => {
    console.log('http://127.0.0.1:8000');
})